#include<iostream>
#include<string.h>
#include<stdlib.h>
using namespace std;
typedef struct{
	int data[2001];
	int length;
} SqList;

void InitList(SqList *&L)
{  
	L=(SqList *)malloc(sizeof(SqList));
	L->length=0; 
}
void CreateList(SqList *&L,int a[],int n)
{
	int i;    
 	L=(SqList *)malloc(sizeof(SqList));
 	for (i=0;i<n;i++)  
    	L->data[i]=a[i];
 	L->length=n; 
}
bool GetElem(SqList *L,int i,int &e)
{ 	
    cout<<L->data[i+1]<<" ";
	cout<<L->data[i-1]<<endl;
	e=L->data[i]; 
    return true;  
}
int num[2001];
int n,x,y,c,e=0,s=0;
int main(){
	cin>>c;
	SqList *L;
	for(int i=0;i<c;i++){
		cin>>n>>x>>y;
		for(int i=0;i<n;i++){
		cin>>num[i];
		}
		for(s=n;s>=0;s--){
		if(num[s]>x&&num[s]<y){
			break;
		}
	} 
	CreateList(L,num,n);
	GetElem(L,s,e);
	}
}
